# -*- coding: utf-8 -*-
import json
import time
import requests

s_txt = open('s_txt.txt','a')
t_uri = 'http://xxxxxx.com/server/api/v1/search_devices.php'
hh = {'Content-Type': 'application/json;charset=UTF-8',
      'Cookie': 'PHPSESSID=',
      'Accept-Language': 'zh-CN,zh;q=0.9',
}
s = requests.Session()
s.headers = hh
with open('set.json','r',buffering=1024) as f:
    data = json.load(f)
    for i in data['data']['assets_tag']:
        data['data']['assets_tag'] = i
        r = s.post(t_uri, json=data)
        if r.json()['count'] == 0:
            s_txt.write(i + ',' + 'NULL\n')
        else:
            s_txt.write(i + ',' + r.json()['info'][0]['position'] + '\n')


